import { defineStore } from 'pinia';
import { Session } from '/@/utils/storage';
import { getDeviceAccessToken } from '/@/api/common';

/**
 * @function useDeviceToken
 * @returns {DeviceTokenStore}
 */
export const useDeviceToken = defineStore('deviceToken', {
    state: () => ({
        deviceToken: '',
    }),

    actions: {
        async setDeviceToken() {
            const data = await getDeviceAccessToken();
            if (data.code == 0) {
                this.deviceToken = data.data;
                Session.set('deviceToken', data.data);
            }
        },
    },
});
